#ifndef LOGINWIDGET_H
#define LOGINWIDGET_H

#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QComboBox>
#include <QFormLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QPaintEvent>
#include <QPainter>
#include <QPen>
#include <QDebug>

#include "../Register/register.h"
#include "../HomeWindow/homepage.h"
#include "../Tools/clienttcp.h"
#include "../Entities/User.h"
#include "../Entities/Doctor.h"

#define FAILTED_CODE ("failed")

#include "../Tools/databasehandler.h"
#include"../HomeWindow/doctorfunctionwidget.h"


class LoginWidget : public QWidget {
    Q_OBJECT

public:
    LoginWidget(QWidget *parent = nullptr);

public slots:
    void onLoginClicked();      // 登录按钮点击槽函数
    void onRegisterClicked();   // 注册按钮点击槽函数

    void showLoginWidget(); // 槽，用于显示登录页面

protected:
    void paintEvent(QPaintEvent *event) override; // 重写绘制事件

signals:
    void requestRegistration(const QString &username, const QString &password);

private:
    QLineEdit *usernameInput;
    QLineEdit *passwordInput;
    QPushButton *loginButton;
    QPushButton *registerButton;
    ClientTcp *tcp;
    Register *registerWidget;
    User *user;
    Doctor *doctor;
    QString role;
    int currentID;
    QComboBox *roleSelect;
    HomePage *home;
    doctorFunctionWidget *doctorfunctionWidget;
};

#endif // LOGINWIDGET_H
